package com.sgb.jicai.view.adapter;

import android.content.Context;
import android.widget.TextView;

import com.sgb.jicai.R;
import com.sgb.jicai.databinding.ItemQuotedPriceContentChildListBinding;
import com.sgb.jicai.entity.JiCaiQuotedPriceCompanyEntity;
import com.swgk.core.BR;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

/**
 * 报价内容页面列表适配器
 */
public class QuotedContentChildItemAdapter extends BaseRecycleAdapter<JiCaiQuotedPriceCompanyEntity.AttrlistEntity> {
    private Context context;
    private String unitNme = "";

    private int priceWarning;

    public QuotedContentChildItemAdapter(Context context, List<JiCaiQuotedPriceCompanyEntity.AttrlistEntity> datas, String unitNme, int priceWarning) {
        super(context, R.layout.item_quoted_price_content_child_list, datas);
        this.context = context;
        this.unitNme = unitNme;
        this.priceWarning = priceWarning;
    }

    @Override
    public void convert(ItemViewHolder holder, JiCaiQuotedPriceCompanyEntity.AttrlistEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        ((ItemQuotedPriceContentChildListBinding) holder.getmBinding()).tvUnitname.setText(unitNme);
        updatViewColor(((ItemQuotedPriceContentChildListBinding) holder.getmBinding()).tvNum);
        updatViewColor(((ItemQuotedPriceContentChildListBinding) holder.getmBinding()).tvUnitname);
        updatViewColor(((ItemQuotedPriceContentChildListBinding) holder.getmBinding()).tvPrice);
    }

    private void updatViewColor(TextView textView) {
        switch (priceWarning) {//价格预警 1 大于 2 等于 3 小于
            case 1:
                textView.setTextColor(context.getResources().getColor(R.color.color_FF4B10));
                break;
            case 2:
                textView.setTextColor(context.getResources().getColor(R.color.new_blue));
                break;
            case 3:
                textView.setTextColor(context.getResources().getColor(R.color.color_06C764));
                break;
            default:
                textView.setTextColor(context.getResources().getColor(R.color.new_blue));
                break;
        }
    }


}
